reverse a string without using inbuilt functions